using System;
using System.Collections;
using System.DirectoryServices;

namespace BEGDC.CC.Entity
{
	#region LogisticalInfo

	/// <summary>
	/// LogisticalInfo object for NHibernate mapped table 'LogisticalInfo'.
	/// </summary>
	[Serializable]
	public class LogisticalInfo : System.IComparable
		{
		#region Member Variables
		
		protected int _id;
		protected bool _isNeedHotel;
		protected string _hotelPreferences;
		protected Nullables.NullableDateTime _dateRequiredFrom;
		protected Nullables.NullableDateTime _dateRequiredTo;
		protected decimal _priceFrom;
		protected decimal _priceTo;
		protected bool _isNeedGroundTransportation;
		protected bool _isNeedEntertainment;
		protected string _entertainmentPreference;
		protected decimal _entertainmentPriceFrom;
		protected decimal _entertainmentPriceTo;
		protected bool _isNeedGift;
		protected decimal _giftPriceFrom;
		protected decimal _giftPriceTo;
		protected string _giftDetails;
		protected bool _isReceivedALGiftBefore;
		protected string _receivedGiftDetails;
		protected bool _isNeedInterpreter;
		protected int _interpretionType;
		protected string _specialDialect;
		protected bool _isMealReservation;
		protected string _mealReservation;
		protected decimal _averageMealCost;
		protected bool _isNeedCatering;
		protected string _cateringDescription;
		protected bool _isNeedTravelAgency;
		protected string _travelAgency;
		protected string _itinerary;
		protected int _duration;
		protected string _arrivalFlightNo;
		protected string _departureFlightNo;
		protected string _arrivalAirport;
		protected string _departureAirport;
		protected Nullables.NullableDateTime _arrivalTime;
		protected Nullables.NullableDateTime _departureTime;
		protected string _comment;
		protected string _hotelcomment;
        protected string _meetingNeeds;
        protected string _otherMeetingNeeds;
        protected bool _isNormalBusiness;
		protected string _giftPreference;
		protected DicItem _meetingRoom;
		protected DicItem _PaymentForHotel;
		protected Application _application;
		protected IList _hotelRoomBookings;
		protected IList _vehicleBookings;
		protected static String _sortExpression = "Id";
		protected static SortDirection _sortDirection = SortDirection.Ascending;

		#endregion

		#region Constructors

		public LogisticalInfo() { }

        public LogisticalInfo(bool isNeedHotel, string hotelPreferences, Nullables.NullableDateTime dateRequiredFrom, Nullables.NullableDateTime dateRequiredTo, decimal priceFrom, decimal priceTo, bool isNeedGroundTransportation, bool isNeedEntertainment, bool isNormalBusiness, string entertainmentPreference, decimal entertainmentPriceFrom, decimal entertainmentPriceTo, bool isNeedGift, decimal giftPriceFrom, decimal giftPriceTo, string giftDetails, bool isReceivedALGiftBefore, string receivedGiftDetails, bool isNeedInterpreter, int interpretionType, string specialDialect, bool isMealReservation, string mealReservation, decimal averageMealCost, bool isNeedCatering, string cateringDescription, bool isNeedTravelAgency, string travelAgency, string itinerary, int duration, string arrivalFlightNo, string departureFlightNo, string arrivalAirport, string departureAirport, Nullables.NullableDateTime arrivalTime, Nullables.NullableDateTime departureTime, string comment, string hotelcomment, string meetingNeeds, string otherMeetingNeeds, string giftPreference, DicItem meetingRoom, DicItem PaymentForHotel, Application application)
		{
			this._isNeedHotel = isNeedHotel;
			this._hotelPreferences = hotelPreferences;
			this._dateRequiredFrom = dateRequiredFrom;
			this._dateRequiredTo = dateRequiredTo;
			this._priceFrom = priceFrom;
			this._priceTo = priceTo;
			this._isNeedGroundTransportation = isNeedGroundTransportation;
			this._isNeedEntertainment = isNeedEntertainment;
			this._entertainmentPreference = entertainmentPreference;
			this._entertainmentPriceFrom = entertainmentPriceFrom;
			this._entertainmentPriceTo = entertainmentPriceTo;
			this._isNeedGift = isNeedGift;
			this._giftPriceFrom = giftPriceFrom;
			this._giftPriceTo = giftPriceTo;
			this._giftDetails = giftDetails;
			this._isReceivedALGiftBefore = isReceivedALGiftBefore;
			this._receivedGiftDetails = receivedGiftDetails;
			this._isNeedInterpreter = isNeedInterpreter;
			this._interpretionType = interpretionType;
			this._specialDialect = specialDialect;
			this._isMealReservation = isMealReservation;
			this._mealReservation = mealReservation;
			this._averageMealCost = averageMealCost;
			this._isNeedCatering = isNeedCatering;
			this._cateringDescription = cateringDescription;
			this._isNeedTravelAgency = isNeedTravelAgency;
			this._travelAgency = travelAgency;
			this._itinerary = itinerary;
			this._duration = duration;
			this._arrivalFlightNo = arrivalFlightNo;
			this._departureFlightNo = departureFlightNo;
			this._arrivalAirport = arrivalAirport;
			this._departureAirport = departureAirport;
			this._arrivalTime = arrivalTime;
			this._departureTime = departureTime;
			this._comment = comment;
			this._hotelcomment = hotelcomment;
            this._meetingNeeds = meetingNeeds;
            this._otherMeetingNeeds = otherMeetingNeeds;
            this._isNormalBusiness = isNormalBusiness;
			this._giftPreference = giftPreference;
			this._meetingRoom = meetingRoom;
			this._PaymentForHotel = PaymentForHotel;
			this._application = application;
		}

		#endregion

		#region Public Properties

		public int Id
		{
			get {return _id;}
			set {_id = value;}
		}

		public bool IsNeedHotel
		{
			get { return _isNeedHotel; }
			set { _isNeedHotel = value; }
		}

		public string HotelPreferences
		{
			get { return _hotelPreferences; }
			set
			{
				if ( value != null && value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for HotelPreferences", value, value.ToString());
				_hotelPreferences = value;
			}
		}

		public Nullables.NullableDateTime DateRequiredFrom
		{
			get { return _dateRequiredFrom; }
			set { _dateRequiredFrom = value; }
		}

		public Nullables.NullableDateTime DateRequiredTo
		{
			get { return _dateRequiredTo; }
			set { _dateRequiredTo = value; }
		}

		public decimal PriceFrom
		{
			get { return _priceFrom; }
			set { _priceFrom = value; }
		}

		public decimal DecryptedPriceFrom
		{
			get { return EncryptHelper.Decrypt(_priceFrom); }
			set { _priceFrom = EncryptHelper.Encrypt(value); }
		}

		public decimal PriceTo
		{
			get { return _priceTo; }
			set { _priceTo = value; }
		}

		public decimal DecryptedPriceTo
		{
			get { return EncryptHelper.Decrypt(_priceTo); }
			set { _priceTo = EncryptHelper.Encrypt(value); }
		}

		public bool IsNeedGroundTransportation
		{
			get { return _isNeedGroundTransportation; }
			set { _isNeedGroundTransportation = value; }
		}

		public bool IsNeedEntertainment
		{
			get { return _isNeedEntertainment; }
			set { _isNeedEntertainment = value; }
		}

		public string EntertainmentPreference
		{
			get { return _entertainmentPreference; }
			set
			{
				if ( value != null && value.Length > 250)
					value = value.Substring(0, 250 );
				_entertainmentPreference = value;
			}
		}

		//TODO: encrypt, add by kevin
		public decimal EntertainmentPriceFrom
		{
			get { return _entertainmentPriceFrom; }
			set { _entertainmentPriceFrom = value; }
		}

		public decimal DecryptedEntertainmentPriceFrom
		{
			get { return EncryptHelper.Decrypt(_entertainmentPriceFrom); }
			set { _entertainmentPriceFrom = EncryptHelper.Encrypt(value); }
		}

		//TODO: encrypt, add by kevin
		public decimal EntertainmentPriceTo
		{
			get { return _entertainmentPriceTo; }
			set { _entertainmentPriceTo = value; }
		}

		public decimal DecryptedEntertainmentPriceTo
		{
			get { return EncryptHelper.Decrypt(_entertainmentPriceTo); }
			set { _entertainmentPriceTo = EncryptHelper.Encrypt(value); }
		}

		public bool IsNeedGift
		{
			get { return _isNeedGift; }
			set { _isNeedGift = value; }
		}

		//TODO: encrypt, add by kevin
		public decimal GiftPriceFrom
		{
			get { return _giftPriceFrom; }
			set { _giftPriceFrom = value; }
		}

		public decimal DecryptedGiftPriceFrom
		{
			get { return EncryptHelper.Decrypt(_giftPriceFrom); }
			set { _giftPriceFrom = EncryptHelper.Encrypt(value); }
		}

		//TODO: encrypt, add by kevin
		public decimal GiftPriceTo
		{
			get { return _giftPriceTo; }
			set { _giftPriceTo = value; }
		}

		public decimal DecryptedGiftPriceTo
		{
			get { return EncryptHelper.Decrypt(_giftPriceTo); }
			set { _giftPriceTo = EncryptHelper.Encrypt(value); }
		}

		public string GiftDetails
		{
			get { return _giftDetails; }
			set
			{
				if ( value != null && value.Length > 250)
					value = value.Substring(0, 250 );
				_giftDetails = value;
			}
		}

		public bool IsReceivedALGiftBefore
		{
			get { return _isReceivedALGiftBefore; }
			set { _isReceivedALGiftBefore = value; }
		}

		public string ReceivedGiftDetails
		{
			get { return _receivedGiftDetails; }
			set
			{
				if ( value != null && value.Length > 250)
					value = value.Substring(0, 250 );
				_receivedGiftDetails = value;
			}
		}

		public bool IsNeedInterpreter
		{
			get { return _isNeedInterpreter; }
			set { _isNeedInterpreter = value; }
		}

		public int InterpretionType
		{
			get { return _interpretionType; }
			set { _interpretionType = value; }
		}

		public string SpecialDialect
		{
			get { return _specialDialect; }
			set
			{
				if ( value != null && value.Length > 20)
					throw new ArgumentOutOfRangeException("Invalid value for SpecialDialect", value, value.ToString());
				_specialDialect = value;
			}
		}

		public bool IsMealReservation
		{
			get { return _isMealReservation; }
			set { _isMealReservation = value; }
		}

		public string MealReservation
		{
			get { return _mealReservation; }
			set
			{
				if ( value != null && value.Length > 250)
					value = value.Substring(0, 250 );
				_mealReservation = value;
			}
		}

		public decimal AverageMealCost
		{
			get { return _averageMealCost; }
			set { _averageMealCost = value; }
		}

		public bool IsNeedCatering
		{
			get { return _isNeedCatering; }
			set { _isNeedCatering = value; }
		}

		public string CateringDescription
		{
			get { return _cateringDescription; }
			set
			{
				if ( value != null && value.Length > 500)
					value = value.Substring(0, 500 );
				_cateringDescription = value;
			}
		}

		public bool IsNeedTravelAgency
		{
			get { return _isNeedTravelAgency; }
			set { _isNeedTravelAgency = value; }
		}

		public string TravelAgency
		{
			get { return _travelAgency; }
			set
			{
				if ( value != null && value.Length > 50)
					value = value.Substring(0, 50 );
				_travelAgency = value;
			}
		}

		public string Itinerary
		{
			get { return _itinerary; }
			set
			{
				if ( value != null && value.Length > 500)
					value = value.Substring(0, 500 );
				_itinerary = value;
			}
		}

		public int Duration
		{
			get { return _duration; }
			set { _duration = value; }
		}

		public string ArrivalFlightNo
		{
			get { return _arrivalFlightNo; }
			set
			{
				if ( value != null && value.Length > 20)
					value = value.Substring(0, 20 );
				_arrivalFlightNo = value;
			}
		}

		public string DepartureFlightNo
		{
			get { return _departureFlightNo; }
			set
			{
				if ( value != null && value.Length > 20)
					value = value.Substring(0, 20 );
				_departureFlightNo = value;
			}
		}

		public string ArrivalAirport
		{
			get { return _arrivalAirport; }
			set
			{
				if ( value != null && value.Length > 20)
					value = value.Substring(0, 20 );
				_arrivalAirport = value;
			}
		}

		public string DepartureAirport
		{
			get { return _departureAirport; }
			set
			{
				if ( value != null && value.Length > 20)
					value = value.Substring(0, 20 );
				_departureAirport = value;
			}
		}

		public Nullables.NullableDateTime ArrivalTime
		{
			get { return _arrivalTime; }
			set { _arrivalTime = value; }
		}

		public Nullables.NullableDateTime DepartureTime
		{
			get { return _departureTime; }
			set { _departureTime = value; }
		}

		public string Comment
		{
			get { return _comment; }
			set
			{
				if ( value != null && value.Length > 500)
					value = value.Substring(0, 500 );
				_comment = value;
			}
		}

		public string HotelComment
		{
			get { return _hotelcomment; }
			set
			{
				if ( value != null && value.Length > 500)
					value = value.Substring(0, 500 );
				_hotelcomment = value;
			}
		}

        public string MeetingNeeds
        {
            get { return _meetingNeeds; }
            set
            {
                if (value != null && value.Length > 500)
                    value = value.Substring(0, 500);
                _meetingNeeds = value;
            }
        }

        public string OtherMeetingNeeds
        {
            get { return _otherMeetingNeeds; }
            set
            {
                if (value != null && value.Length > 500)
                    value = value.Substring(0, 500);
                _otherMeetingNeeds = value;
            }
        }

        public bool IsNormalBusiness
        {
            get { return _isNormalBusiness; }
            set { _isNormalBusiness = value; }
        }

		public string GiftPreference
		{
			get { return _giftPreference; }
			set
			{
				if ( value != null && value.Length > 50)
					value = value.Substring(0, 50 );
				_giftPreference = value;
			}
		}

		public DicItem MeetingRoom
		{
			get { return _meetingRoom; }
			set { _meetingRoom = value; }
		}

		public DicItem PaymentForHotel
		{
			get { return _PaymentForHotel; }
			set { _PaymentForHotel = value; }
		}

		public Application Application
		{
			get { return _application; }
			set { _application = value; }
		}

		public IList HotelRoomBookings
		{
			get
			{
				if (_hotelRoomBookings==null)
				{
					_hotelRoomBookings = new ArrayList();
				}
				return _hotelRoomBookings;
			}
			set { _hotelRoomBookings = value; }
		}

		public IList VehicleBookings
		{
			get
			{
				if (_vehicleBookings==null)
				{
					_vehicleBookings = new ArrayList();
				}
				return _vehicleBookings;
			}
			set { _vehicleBookings = value; }
		}

        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
		#endregion
		
        #region IComparable Methods
        public int CompareTo(object obj)
        {
			if (!(obj is LogisticalInfo))
				throw new InvalidCastException("This object is not of type LogisticalInfo");
			
			int relativeValue;
			switch (SortExpression)
			{
				case "Id":
					relativeValue = this.Id.CompareTo(((LogisticalInfo)obj).Id);
					break;
				case "IsNeedHotel":
					relativeValue = this.IsNeedHotel.CompareTo(((LogisticalInfo)obj).IsNeedHotel);
					break;
				case "HotelPreferences":
						relativeValue = ( this.HotelPreferences != null ) ? this.HotelPreferences.CompareTo(((LogisticalInfo)obj).HotelPreferences) : -1;
					break;
				case "DateRequiredFrom":
						relativeValue = ( this.DateRequiredFrom != null ) ? this.DateRequiredFrom.CompareTo(((LogisticalInfo)obj).DateRequiredFrom) : -1;
					break;
				case "DateRequiredTo":
						relativeValue = ( this.DateRequiredTo != null ) ? this.DateRequiredTo.CompareTo(((LogisticalInfo)obj).DateRequiredTo) : -1;
					break;
				case "PriceFrom":
					relativeValue = this.PriceFrom.CompareTo(((LogisticalInfo)obj).PriceFrom);
					break;
				case "PriceTo":
					relativeValue = this.PriceTo.CompareTo(((LogisticalInfo)obj).PriceTo);
					break;
				case "IsNeedGroundTransportation":
					relativeValue = this.IsNeedGroundTransportation.CompareTo(((LogisticalInfo)obj).IsNeedGroundTransportation);
					break;
				case "IsNeedEntertainment":
					relativeValue = this.IsNeedEntertainment.CompareTo(((LogisticalInfo)obj).IsNeedEntertainment);
					break;
				case "EntertainmentPreference":
					relativeValue = this.EntertainmentPreference.CompareTo(((LogisticalInfo)obj).EntertainmentPreference);
					break;
				case "EntertainmentPriceFrom":
					relativeValue = this.DecryptedEntertainmentPriceFrom.CompareTo(((LogisticalInfo)obj).DecryptedEntertainmentPriceFrom);
					break;
				case "EntertainmentPriceTo":
					relativeValue = this.DecryptedEntertainmentPriceTo.CompareTo(((LogisticalInfo)obj).DecryptedEntertainmentPriceTo);
					break;
				case "IsNeedGift":
					relativeValue = this.IsNeedGift.CompareTo(((LogisticalInfo)obj).IsNeedGift);
					break;
				case "GiftPriceFrom":
					relativeValue = this.DecryptedGiftPriceFrom.CompareTo(((LogisticalInfo)obj).DecryptedGiftPriceFrom);
					break;
				case "GiftPriceTo":
					relativeValue = this.DecryptedGiftPriceTo.CompareTo(((LogisticalInfo)obj).DecryptedGiftPriceTo);
					break;
				case "GiftDetails":
						relativeValue = ( this.GiftDetails != null ) ? this.GiftDetails.CompareTo(((LogisticalInfo)obj).GiftDetails) : -1;
					break;
				case "IsReceivedALGiftBefore":
					relativeValue = this.IsReceivedALGiftBefore.CompareTo(((LogisticalInfo)obj).IsReceivedALGiftBefore);
					break;
				case "ReceivedGiftDetails":
						relativeValue = ( this.ReceivedGiftDetails != null ) ? this.ReceivedGiftDetails.CompareTo(((LogisticalInfo)obj).ReceivedGiftDetails) : -1;
					break;
				case "IsNeedInterpreter":
					relativeValue = this.IsNeedInterpreter.CompareTo(((LogisticalInfo)obj).IsNeedInterpreter);
					break;
				case "InterpretionType":
					relativeValue = this.InterpretionType.CompareTo(((LogisticalInfo)obj).InterpretionType);
					break;
				case "SpecialDialect":
						relativeValue = ( this.SpecialDialect != null ) ? this.SpecialDialect.CompareTo(((LogisticalInfo)obj).SpecialDialect) : -1;
					break;
				case "IsMealReservation":
						relativeValue = ( this.IsMealReservation != Convert.ToBoolean( null) ) ? this.IsMealReservation.CompareTo(((LogisticalInfo)obj).IsMealReservation) : -1;				
					break;
				case "MealReservation":
						relativeValue = ( this.MealReservation != null ) ? this.MealReservation.CompareTo(((LogisticalInfo)obj).MealReservation) : -1;
					break;
				case "AverageMealCost":
						relativeValue = ( this.AverageMealCost != Convert.ToDecimal( null) ) ? this.AverageMealCost.CompareTo(((LogisticalInfo)obj).AverageMealCost) : -1;
					break;
				case "IsNeedCatering":
					relativeValue = this.IsNeedCatering.CompareTo(((LogisticalInfo)obj).IsNeedCatering);
					break;
				case "CateringDescription":
						relativeValue = ( this.CateringDescription != null ) ? this.CateringDescription.CompareTo(((LogisticalInfo)obj).CateringDescription) : -1;
					break;
				case "IsNeedTravelAgency":
					relativeValue = this.IsNeedTravelAgency.CompareTo(((LogisticalInfo)obj).IsNeedTravelAgency);
					break;
				case "TravelAgency":
						relativeValue = ( this.TravelAgency != null ) ? this.TravelAgency.CompareTo(((LogisticalInfo)obj).TravelAgency) : -1;
					break;
				case "Itinerary":
						relativeValue = ( this.Itinerary != null ) ? this.Itinerary.CompareTo(((LogisticalInfo)obj).Itinerary) : -1;
					break;
				case "Duration":
					relativeValue = this.Duration.CompareTo(((LogisticalInfo)obj).Duration);
					break;
				case "ArrivalFlightNo":
						relativeValue = ( this.ArrivalFlightNo != null ) ? this.ArrivalFlightNo.CompareTo(((LogisticalInfo)obj).ArrivalFlightNo) : -1;
					break;
				case "DepartureFlightNo":
						relativeValue = ( this.DepartureFlightNo != null ) ? this.DepartureFlightNo.CompareTo(((LogisticalInfo)obj).DepartureFlightNo) : -1;
					break;
				case "ArrivalAirport":
						relativeValue = ( this.ArrivalAirport != null ) ? this.ArrivalAirport.CompareTo(((LogisticalInfo)obj).ArrivalAirport) : -1;
					break;
				case "DepartureAirport":
						relativeValue = ( this.DepartureAirport != null ) ? this.DepartureAirport.CompareTo(((LogisticalInfo)obj).DepartureAirport) : -1;
					break;
				case "ArrivalTime":
						relativeValue = ( this.ArrivalTime != null ) ? this.ArrivalTime.CompareTo(((LogisticalInfo)obj).ArrivalTime) : -1;
					break;
				case "DepartureTime":
						relativeValue = ( this.DepartureTime != null ) ? this.DepartureTime.CompareTo(((LogisticalInfo)obj).DepartureTime) : -1;
					break;
				case "Comment":
						relativeValue = ( this.Comment != null ) ? this.Comment.CompareTo(((LogisticalInfo)obj).Comment) : -1;
					break;
				case "GiftPreference":
						relativeValue = ( this.GiftPreference != null ) ? this.GiftPreference.CompareTo(((LogisticalInfo)obj).GiftPreference) : -1;
					break;
                default:
                    goto case "Id";
			}
            if (LogisticalInfo.SortDirection == SortDirection.Ascending)
				relativeValue *= -1;
			return relativeValue;
		}
		#endregion
	}

	#endregion
}
